package com.service.atf.base.model;

import com.service.atf.base.core.ByteConvertion;
import com.luotao.devp.base.utils.ByteUtil;

/**
 * User: luotao
 * Date: 12-2-23
 * Time: 15:49:0
 */
public class TFReg extends BaseHeader implements ByteConvertion {


    private String loginName;

    private String loginPass;

    private String nickname;

    private String mobile;

    private String realname;

    private byte cardtype;

    private String cardId;

    private String bankcode;

    private String bankcardId;

    private String tradePass;

    private String email;

    private int createdate;

    public TFReg() {
        setType((byte) '1');
        setTradeType((byte) '7');
    }

    public String getBankcode() {
        return bankcode;
    }

    public void setBankcode(String bankcode) {
        this.bankcode = bankcode;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getLoginPass() {
        return loginPass;
    }

    public void setLoginPass(String loginPass) {
        this.loginPass = loginPass;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getRealname() {
        return realname;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    public byte getCardtype() {
        return cardtype;
    }

    public void setCardtype(byte cardtype) {
        this.cardtype = cardtype;
    }

    public String getCardId() {
        return cardId;
    }

    public void setCardId(String cardId) {
        this.cardId = cardId;
    }

    public String getBankcardId() {
        return bankcardId;
    }

    public void setBankcardId(String bankcardId) {
        this.bankcardId = bankcardId;
    }

    public String getTradePass() {
        return tradePass;
    }

    public void setTradePass(String tradePass) {
        this.tradePass = tradePass;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public int getCreatedate() {
        return createdate;
    }

    public void setCreatedate(int createdate) {
        this.createdate = createdate;
    }

    @Override
    public ByteConvertion byte2Object(byte[] src) {
        byte2ObjectHeader(src);
        setLoginName(ByteUtil.readString(src, LEN_HEAD, 20));
        setLoginPass(ByteUtil.readString(src, LEN_HEAD + 20, 32));
        setNickname(ByteUtil.readString(src, LEN_HEAD + 52, 20));
        setMobile(ByteUtil.readString(src, LEN_HEAD + 72, 11));
        setRealname(ByteUtil.readString(src, LEN_HEAD + 83, 10));
        setCardtype((byte) ByteUtil.read(src, LEN_HEAD + 93));
        setCardId(ByteUtil.readString(src, LEN_HEAD + 94, 20));
        setBankcode(ByteUtil.readString(src, LEN_HEAD + 114, 10));
        setBankcardId(ByteUtil.readString(src, LEN_HEAD + 124, 20));
        setTradePass(ByteUtil.readString(src, LEN_HEAD + 144, 32));
        setEmail(ByteUtil.readString(src, LEN_HEAD + 176, 50));
        setCreatedate(ByteUtil.readInt(src, LEN_HEAD + 226));
        return this;
    }

    @Override
    public byte[] object2Byte() {
        byte[] head = object2ByteHeader();
        byte[] result = new byte[LEN_HEAD + 230];
        System.arraycopy(head, 0, result, 0, head.length);
        ByteUtil.writeString(result, LEN_HEAD, getLoginName(), 20);
        ByteUtil.writeString(result, LEN_HEAD + 20, getLoginPass(), 32);
        ByteUtil.writeString(result, LEN_HEAD + 52, getNickname(), 20);
        ByteUtil.writeString(result, LEN_HEAD + 72, getMobile(), 11);
        ByteUtil.writeString(result, LEN_HEAD + 83, getRealname(), 10);
        ByteUtil.write(result, LEN_HEAD + 93, getCardtype());
        ByteUtil.writeString(result, LEN_HEAD + 94, getCardId(), 20);
        ByteUtil.writeString(result, LEN_HEAD + 114, getBankcode(), 10);
        ByteUtil.writeString(result, LEN_HEAD + 124, getBankcardId(), 20);
        ByteUtil.writeString(result, LEN_HEAD + 144, getTradePass(), 32);
        ByteUtil.writeString(result, LEN_HEAD + 176, getEmail(), 50);
        ByteUtil.writeInt(result, LEN_HEAD + 226, getCreatedate());
        return result;
    }
}
